# -*- coding: utf-8 -*-
from django.db import models
import time
import datetime

# 虚拟目录
class VDir(models.Model):
    name = models.CharField(max_length=64)
    create_date = models.DateTimeField(auto_now_add = True)
    update_date = models.DateTimeField(auto_now_add = True)
    parent=models.ForeignKey('self',null=True,blank=True)
    ver = models.IntegerField(default=0)

    def __unicode__(self):
    	return self.name


    def get_full_path(self):
        if self.parent:
            return '%s%s/' % (self.parent.get_full_path(),self.name)
        else:
            return '/%s/' % self.name


    def add_ver(self):
        self.ver=self.ver+1
        if self.parent:self.parent.add_ver()
        self.update_date=datetime.datetime.now()
        self.save()